<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<html>
<head>
  <%@ include file="/common/meta.jsp" %>
  <title>查询条件</title>
  <script type="text/javascript">
    $(function(){
        /*绑定方法下拉框*/
        $("#functionName").ligerComboBox({
            url: '',
            valueField: 'id',
            textField: 'typeName',
            valueFieldID: 'functionId',
            selectBoxWidth: 170,
            autocomplete: true,
            width: 170,
            keySupport: true,
            highLight:true
        });

        /*绑定编辑页面下拉框*/
        $("#editPageName").ligerComboBox({
            valueField: 'id',
            textField: 'typeName',
            valueFieldID: 'editPageId',
            selectBoxWidth: 170,
            autocomplete: true,
            width: 170,
            keySupport: true,
            highLight:true
        });
        /*绑定查看页面下拉框*/
        $("#viewPageName").ligerComboBox({
            valueField: 'id',
            textField: 'typeName',
            valueFieldID: 'viewPageId',
            selectBoxWidth: 170,
            autocomplete: true,
            width: 170,
            keySupport: true,
            highLight:true
        });
        $("#mainGrid").ligerGrid({
            columns: [
                { display: 'id', name: 'id', hide: true, width: 60 },
                { display: '序号', width: 40, render: function (rowData, rowindex, value, column, rowid, page, pagesize) { return (page - 1) * pagesize + rowindex + 1; } },
                { display: '岗位名称', name: 'hostName', align: 'center', width: 180 },
                { display: '岗位路径', name: 'postPath', align: 'center', width: 160 },
                { display: '岗位代码', name: 'postCode', align: 'left', width: 160 }
            ],
            width: '100%', heightDiff: -1,
            usePager:false,
            checkbox:true
        });

        /*接收并初始化节点*/
        /*$("#currentNodeName").val(nodeObj['${currentNodeId}'].name);
        for(var node in nodeObj){
            var nodeChild = nodeObj[node];
            if(nodeChild.type != "start round" && node != '${currentNodeId}'){
                $("#node").append("<option value='"+node+"'>"+nodeChild.name+"</option>");
            }
        }*/
        $("#navtab1").ligerTab();

        /*执行人单选按钮的切换*/
        $("input[type=radio]").click(function(){
            $(".post:eq("+$(this).index()+")").show().siblings().hide();
        });
    });

    var nodeStr = sessionStorage.getItem("nodeStr");
    var nodeObj = JSON.parse(nodeStr);
    /*创建通知 json对像*/
    function noticesJson(){
        var notices = [];
        if($("#noticeTitle").val()=="" || $("#noticeContent").val() == ""){
            return "";
        }
        var noticeJson = [{fkId:'${currentUser}',fkType:'${userType}',noticeWay:$("#noticeWay").val(),
            title:$("#noticeTitle").val(),content:$("#noticeContent").val()}];
        return noticeJson;
    }
      /*创建单个节点的json对象*/
      function createJson(){
          var allowStop = 0;
          var allowRecall = 0;
          var allowHang = 0;
          if($("#allowStop").get(0).checked){
              allowStop = 1;
          }
          if($("#allowRecall").get(0).checked){
              allowRecall = 1;
          }
          if($("#allowHang").get(0).checked){
              allowHang = 1;
          }
          var fkType="";
          var radios = $("input[type=radio]");
          for(var i=0;i<radios.length;i++){
              if(radios[i].checked){
                  fkType = radios[i].value;
              }
          }
          //定义json对象的模型，并赋值
        var ret = {type:nodeObj['${currentNodeId}'].type,fkId:'${currentUser}',fkType:fkType, allowStop:allowStop, allowRecall:allowRecall,
            allowHang:allowHang, functionId:null,editPageId:$("#editPage").val(),viewPageId:$("#viewPage").val(),notices:noticesJson()};
          /*判断： 把没有值的属性删除*/
          for(var k in ret){
              if(ret[k]==undefined || ret[k] == "" || ret[k] == null){
                  delete ret[k];
              }
          }
          /*把json对象转换成json字符串*/
          var retStr =  JSON.stringify(ret);
          return ret;
      }
  </script>
</head>
<body>
<table style="border-collapse:separate; border-spacing:10px;margin:10px auto;">
  <tr>
    <td>当前节点：</td>
    <td>
        <input type="hidden" id="currentNodeId" name="currentNodeId" style="width: 170px;" value="${currentNodeId}" />
        <input type="text" id="currentNodeName" name="currentNodeName" style="width: 170px;" />
    </td>
  </tr>
  <tr>
    <td>下个节点：</td>
    <td>
      <select id="node" style="width: 173px;">
      </select>
    </td>
  </tr>
  <tr>
    <td>执行方法：</td>
    <td>
      <%--<input type="hidden" id="functionId" name="functionId" />
      <input type="text" id="functionName" name="functionName" />--%>
          <select id="function" style="width: 173px;">
              <option value="adfasdfsdfsd">方法1</option>
              <option value="asfdasdfdfsf">方法2</option>
              <option value="adfasdfewggf">方法3</option>
          </select>
    </td>
  </tr>
  <tr>
    <td colspan="2">
      <input type="checkbox" checked="checked" value="" name="" id="allowStop" />允许流程发起人终止&nbsp;
      <input type="checkbox" checked="checked" value="" name="" id="allowRecall" />能否被上部撤回&nbsp;
      <input type="checkbox" checked="checked" value="" name="" id="allowHang" />允许挂起流程
    </td>
  </tr>
  <tr>
    <td>编辑页面：</td>
    <td>
      <%--<input type="hidden" id="editPageId" name="editPageId" />
      <input type="text" id="editPageName" name="editPageName" />--%>

          <select id="editPage" style="width: 173px;">
              <option value="adfasdfsdfsd">页面1</option>
              <option value="asfdasdfdfsf">页面2</option>
              <option value="adfasdfewggf">页面3</option>
          </select>
    </td>
  </tr>
  <tr>
    <td>查看页面：</td>
    <td>
      <%--<input type="hidden" id="viewPageId" name="viewPageId" />
      <input type="text" id="viewPageName" name="viewPageName" />--%>

          <select id="viewPage" style="width: 173px;">
              <option value="adfasdfsdfsd">查看页面1</option>
              <option value="asfdasdfdfsf">查看页面2</option>
              <option value="adfasdfewggf">查看页面3</option>
          </select>
    </td>
  </tr>
</table>
<div id="navtab1" style="width: 99%; overflow: hidden;margin:0 auto; border: 1px solid #D3D3d3;" class="liger-tab">

  <div tabid="home" title="任务执行人" lselected="true" style="padding:10px;">
    <input type="radio" id="post" name="fkType" value="group" checked="checked" />岗位&nbsp;&nbsp;
    <input type="radio" id="role" name="fkType" value="group" />角色&nbsp;&nbsp;
    <input type="radio" id="organizational" name="fkType" value="group" />组织机构&nbsp;&nbsp;
      <input type="radio" id="executive" name="fkType" value="user" />自定义执行人&nbsp;&nbsp;
      <input type="radio" id="promoter" name="fkType" value="user" />流程发起人
    <div>
        <div class="post" style="margin-top:10px;" >
            <div>
                <input type="button" value="添加" id="addHost" style="padding:2px 10px;" />&nbsp;&nbsp;
                <input type="button" value="删除" id="deleteHost" style="padding:2px 10px;" />
            </div>
            <div id="mainGrid"style="margin-top:10px;">

            </div>
        </div>

        <div class="post" style="margin-top:10px;display:none;">
            角色
        </div>

        <div class="post" style="margin-top:10px;display:none;">
            组织机构
        </div>

        <div class="post" style="margin-top:10px;display:none;">
            自定义执行人
        </div>

        <div class="post" style="margin-top:10px;display:none;text-align: center;">
            备注：由流程发起人执行任务
        </div>
    </div>
  </div>

  <div title="条件控制" showclose="true"style="padding:10px;">
    <input type="button" value="添加" id="add" />&nbsp;
    <input type="button" value="删除选中项" id="delete" />
  </div>

    <div title="通知任务执行人" showclose="true"style="padding:10px;">
        <table style="border-collapse:separate; border-spacing:10px;">
            <tr>
                <td>通知类型：</td>
                <td>
                    <input type="text" id="noticeWay" name="noticeWay" style="width: 170px;" value="Email" disabled="disabled" />
                </td>
            </tr>
            <tr>
                <td>通知标题：</td>
                <td>
                    <input type="text" id="noticeTitle" name="noticeTitle" style="width: 170px;" />
                </td>
            </tr>
            <tr>
                <td valign="top">通知内容：</td>
                <td>
                    <textarea id="noticeContent" name="noticeContent" rows="5" cols="40" ></textarea>
                </td>
            </tr>
        </table>
    </div>

    <%--<div title="通知流程发起人" showclose="true"style="padding:10px;">
        <table style="border-collapse:separate; border-spacing:10px;">
            <tr>
                <td>通知类型：</td>
                <td>
                    <input type="text" id="noticeWay" name="noticeWay" style="width: 170px;" value="Email" disabled="disabled" />
                </td>
            </tr>
            <tr>
                <td>通知标题：</td>
                <td>
                    <input type="text" id="noticeTitle" name="noticeTitle" style="width: 170px;" />
                </td>
            </tr>
            <tr>
                <td valign="top">通知内容：</td>
                <td>
                    <textarea id="noticeContent" name="noticeContent" rows="5" cols="40" ></textarea>
                </td>
            </tr>
        </table>
    </div>--%>
</div>
</body>
</html>
